package com.feng.utils;


import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class BeanCopyUtil {

    public static <T> T articleVo(Object o, Class<T> cla){
        T result = null;
        try {
            result = cla.newInstance();
            BeanUtils.copyProperties(o,result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public static <O,T> List<T> articleListVo(List<O> list, Class<T> cla){
        return list.stream()
                .map(o -> articleVo(o, cla))
                .collect(Collectors.toList());
    }
}
